<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr=["孙悟空","猪八戒","唐僧","沙和尚","张三","王五"]
        function randomNum(max,min){
            return parseInt(Math.random()*(max+1-min))+min;
        }
        var res=randomNum(0,arr.length-1);

        console.log(arr[res]);
    </script>
</body>
</html>